package com.lightsh.utility;

import org.jbox2d.common.Vec2;

import android.view.MotionEvent;

import com.lightsh.gui.BaseScreen;
import com.lightsh.object.CircleObjectImpl;

public class BallObject extends CircleObjectImpl{

	private float mFallVelocity = 100;
	private boolean mPause = false;
	public BallObject(BaseScreen screen, float x, float y, float radius) {
		super(screen, x, y, radius);
	}

	@Override
	public void update() {
		super.update();
		if(!mPause){
			mPosition.y += mParentScreen.getTimeStep() * mFallVelocity;
		}
		
	}

	@Override
	public boolean onTouchEvent(MotionEvent ev, float worldScale, float screenX, float screenY) {
		// FIXME
		if(isPointInside(new Vec2(ev.getX(), ev.getY()), worldScale, screenX, screenY)){
			Debugger.logT("", getPosition() + " -- " + ev.getX() + "," + ev.getY());
			
			if( (ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN){
				mPause = !mPause;
			}			
			return true;
		}
		return false;
	}

	@Override
	public void create() {
		super.create();
		mParentScreen.addTouchListener(this);
	}

	
	
}
